<?php
/**
 *
 */
class panel__rrp__devices_overview
	extends panel__rrp {

	public function __route() {

		return array(

			"overview" => array(

				"is_default" => TRUE

			),

			"get_overview_data" => TRUE

		);

	}	# Function

	public function overview() {

		$template = new panel__template;
		$template->setTemplate("devices_overview/overview.html");

		return $template->fetchTemplate();

	}	# Function

	public function get_overview_data() {

		$R = array();

		$vendors = panel__model__vendors::getVendors( array(

			"join_devices" => array(

				"select_ip" => TRUE,
				"select_vendor" => TRUE

			)

		) );

		foreach( $vendors as $_vendor ) {

			$_item = $_vendor;
			$_item["is_leaf"] = FALSE;

			unset($_item["devices"]);

			$R[] = $_item;

			foreach( $_vendor["devices"] as $_device ) {

				$_item = $_device;
				$_item["is_leaf"] = TRUE;

				$R[] = $_item;

			}	# foreach

		}	# foreach

		$R = A($R)
		->castColumn_("ip", "string")
		->castColumn_("vendor_id", "int")
		->castColumn_("vendor_title", "string")
		->getValues()
		;

		return $R;

	}	# Function

}	# Class

/* EOF */